<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// 
//  index_model.php
//  www.6block.com
//  
//  Created by Will_Lee on 2011-05-17.
//  Copyright 2011 lishuzu. All rights reserved.
// 

class Home_model extends CI_model{
	function __construct(){
		parent::__construct();
		$this->load->model('Activity_model');
		$this->load->model('Goods_model');
		$this->load->model('Collection_model');
	}
	function get_my_colletion($uid){
		if (empty($uid)) {
			return false;
		}
		$mycollections = $this->Collection_model->get_Collection_by_uid($uid);
		foreach ($mycollections as $key => $mycollection) {
			$aids[] = $mycollection['aid'];
		}
		$activitys = $this->Activity_model->get_activitys_by_aids($aids);
		
		foreach ($activitys as $key => $activity) {
			//加密
			$activity['key'] = md5($activity['aid'].'lishuzu7qiaor!@#');
			$activity['goods'] = $this->Goods_model->get_goods($activity['aid']);
			$activity['discount'] = explode('.', $activity['discount']);
			$activity['offset']['int'] = $activity['discount'][0];
			$activity['offset']['decimal'] = $activity['discount'][1];
			$activity['starttime'] = date('Y-m-d H:i:s', $activity['starttime']);
			$activity['endtime'] = date('Y-m-d H:i:s', $activity['endtime']);
			$activity['dateline'] = date('Y-m-d H:i:s', $activity['dateline']);
			$data[] = $activity;
		}
		return $data;
	}
}
/* End of file welcome.php */
/* Location: ./application/controllers/index.php */

?>